


var year = 2019;
var mounth = 5;

document.querySelector("#nian").innerHTML = year;
document.querySelector("#yue").innerHTML = mounth;

var days = 0;
//闰年
function runNian(y){
   if (y % 400 === 0 ||(y % 4 === 0 && y %100 !== 0)) {
         	 	return true;
         	 }else{
         	 	return false;
         	 }
}


//1980-2019

for (var i = 1980; i <year; i++) {
	if (runNian(i)) {
		days += 366;
	}else{
		days += 365;
	}
}

//1月到现在
var dy=0;
for(var k =1; k<mounth; k++){
   switch (k) {
   	 case 1:
   	     dy += 31;
   	     break;
   	 case 2:
   	     if (runNian(year)) {
   	     	dy +=29;
   	     }else{
   	     	dy +=28;
   	     }
   	 case 3:
   	     dy += 31;
   	     break;
   	 case 4:
   	     dy += 30;
   	     break;  
   	 case 5:
   	     dy += 31;
   	     break;
   	 case 6:
   	     dy += 30;
   	     break;
   	 case 7:
   	     dy += 31;
   	     break;
   	 case 8:
   	     dy += 31;
   	     break;
   	 case 9:
   	     dy += 30;
   	     break;
   	 case 10:
   	     dy += 31;
   	     break;
   	 case 11:
   	     dy += 30;
   	     break;
   	 case 12:
   	     dy += 31;
   	     break;
   }
}
//本月
var day = 0;
switch(mounth){
	case 1:
   	     day += 31;
   	     break;
   	 case 2:
   	     if (runNian(year)) {
   	     	day +=29;
   	     }else{
   	     	day +=28;
   	     }
   	 case 3:
   	     day += 31;
   	     break;
   	 case 4:
   	     day += 30;
   	     break;  
   	 case 5:
   	     day += 31;
   	     break;
   	 case 6:
   	     day += 30;
   	     break;
   	 case 7:
   	     day += 31;
   	     break;
   	 case 8:
   	     day += 31;
   	     break;
   	 case 9:
   	     day += 30;
   	     break;
   	 case 10:
   	     day += 31;
   	     break;
   	 case 11:
   	     day += 30;
   	     break;
   	 case 12:
   	     day += 31;
   	     break;
}

//上个月
var prevDay = 0;
switch (mounth - 1){
	case 1:
   	     prevDay += 31;
   	     break;
   	 case 2:
   	     if (runNian(year)) {
   	     	prevDay +=29;
   	     }else{
   	     	prevDay +=28;
   	     }
   	 case 3:
   	     prevDay += 31;
   	     break;
   	 case 4:
   	     prevDay += 30;
   	     break;  
   	 case 5:
   	     prevDay += 31;
   	     break;
   	 case 6:
   	     prevDay += 30;
   	     break;
   	 case 7:
   	     prevDay += 31;
   	     break;
   	 case 8:
   	     prevDay += 31;
   	     break;
   	 case 9:
   	     prevDay += 30;
   	     break;
   	 case 10:
   	     prevDay += 31;
   	     break;
   	 case 11:
   	     prevDay += 30;
   	     break;
   	 case 12:
   	     prevDay += 31;
   	     break;
}

dy += 2;


var start = day % 7;
console.log(start);

var num = 42;

var nextdy = num - start - day;


var thisdate = new Date().getDate();

var date1 = document.querySelector("#date1");

for(var j = prevDay - start + 1; j <= prevDay; j++){
	date1.innerHTML += "<span class='h'>" + j + "</span>";
}

for(var a =1; a <= day; a++){
  if (a == thisdate) {
  	date1.innerHTML += "<span class='today'>" + a + "</span>";
  } else{
  	date1.innerHTML += "<span>" + a + "</span>";
  }
}


for(var s = 1; s <= nextdy; s++){
    date1.innerHTML += "<span class='h'>" + s + "</span>";
}